package com.sxj.springsourcecode.enity.postProcessor;

import com.sxj.springsourcecode.enity.UserService;
import com.sxj.springsourcecode.springframework.factory.config.BeanPostProcessor;
import com.sxj.springsourcecode.springframework.utils.ClassUtil;

/**
 * @ProjectName: spring-source-code
 * @Package: com.sxj.springsourcecode.enity.postProcessor
 * @ClassName: MyBeanPostProcessor
 * @Author: sxj
 * @Description:
 * @Date: 2024/2/22 0:18
 * @Version: 1.0.0
 */
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) {
        Object result = bean;
        if ("userService".equals(beanName)){
            UserService userService = (UserService) bean;
            userService.setAddress("改为：杭州市");
        }
        return result;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) {
        return null;
    }
}
